package jxerializeml.xml;

/**
 * Contains all necessary informations about single field in
 * some object. It's used for transferring these informations
 * between different layers of this library.
 * 
 * @author Tomáš Zíma
 */
public class FieldBean {
	/** Name of the field. */
	private String name = null;
	
	/** Name of the class. */
	private String className = null;
	
	/** Value of the primitive type converted into the String. */
	private String value = null;
	
	/** Length of the array (if it's an array). */
	private Integer length = null;
	
	/**
	 * Additional important informations to the field, which will
	 * appear in the generated XML document.
	 */
	private String comment = null;

	/**
	 * @param name
	 *     Name of the field.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param className
	 *     Name of the class.
	 */
	public void setClassName(String className) {
		this.className = className;
	}

	/**
	 * @param value
	 *     Value of the primitive type converted into the String
	 *     (if it's a primitive type).
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * @param length
	 *     Length of the array (if it's an array).
	 */
	public void setLength(Integer length) {
		this.length = length;
	}
	
	/**
	 * @param comment
	 *     Add additional informations to the field, which
	 *     will appear in the generated XML document.
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	/**
	 * @return
	 *     Name of the field.
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return
	 *     Name of the class.
	 */
	public String getClassName() {
		return className;
	}

	/**
	 * @return
	 *     Value of the primitive type converted into the String
	 *     (if it's a primitive type).
	 */
	public String getValue() {
		return value;
	}
	
	/**
	 * @return
	 *     Length of an array (if it's an array).
	 */
	public Integer getLength() {
		return length;
	}
	
	/**
	 * @return
	 *     Additional informations to the field, which will
	 *     appear in the generated XML document.
	 */
	public String getComment() {
		return comment;
	}

	/**
	 * @return
	 *     True if value was assigned.
	 */
	public boolean hasValue() {
		return value != null;
	}
	
	/**
	 * @return
	 *     True if length was assigned (therefore, it's an array).
	 */
	public boolean hasLength() {
		return length != null;
	}
	
	/**
	 * @return
	 *     True if name of the class was assigned.
	 */
	public boolean hasClassName() {
		return className != null;
	}
	
	/**
	 * @return
	 *     True if comment was assigned.
	 */
	public boolean hasComment() {
		return comment != null;
	}
}
